{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import matplotlib\n",
    "import numpy\n",
    "import math\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "matplotlib.style.use('ggplot')\n",
    "matplotlib.rcParams.update({'font.size': 12})\n",
    "matplotlib.rcParams.update({'xtick.labelsize': 'x-large'})\n",
    "matplotlib.rcParams.update({'xtick.major.size': '0'})\n",
    "matplotlib.rcParams.update({'ytick.labelsize': 'x-large'})\n",
    "matplotlib.rcParams.update({'ytick.major.size': '0'})\n",
    "matplotlib.rcParams.update({\"text.usetex\": True})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "facecolor='C4'\n",
    "edgecolor='C1'\n",
    "vertexcolor='C0'\n",
    "textcolor='k'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# angle\n",
    "x = [-1, 0, 1]\n",
    "y = [0.5, -0.5, -0.1]\n",
    "\n",
    "fig = matplotlib.figure.Figure(figsize=(5, 6.18), dpi=100)\n",
    "ax = fig.add_subplot(aspect='equal')\n",
    "ax.plot(x, y, color=edgecolor, linewidth=3)\n",
    "\n",
    "for i,v in enumerate(zip(x,y)):\n",
    "    ax.plot(v[0], v[1], '.', color=vertexcolor, markersize=15)\n",
    "\n",
    "ax.text(x[0]+0.05,y[0], r'$\\vec{r}_i$', fontsize=20, color=textcolor)\n",
    "ax.text(x[1],y[1]-0.15, r'$\\vec{r}_j$', fontsize=20, color=textcolor)\n",
    "ax.text(x[2]+0.05,y[2], r'$\\vec{r}_k$', fontsize=20, color=textcolor)\n",
    "ax.text(x[1],y[1]+0.22, r'$\\theta$', fontsize=20, color=textcolor)\n",
    "\n",
    "ax.add_patch(matplotlib.patches.Arc([0,-0.5], 0.4, 0.4, angle=0, theta1=25, theta2=135, color=textcolor, linewidth=1.5))\n",
    "    \n",
    "ax.grid(False)\n",
    "ax.axis('off')\n",
    "ax.set_xlim([-1.1, 1.1])\n",
    "ax.set_ylim([-0.6, 0.6])\n",
    "\n",
    "fig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "fig.savefig('../md-angle.svg', bbox_inches='tight', facecolor=(1, 1, 1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# bond\n",
    "x = [-1, 1]\n",
    "y = [0.5, -0.5]\n",
    "\n",
    "fig = matplotlib.figure.Figure(figsize=(5, 6.18), dpi=100)\n",
    "ax = fig.add_subplot(aspect='equal')\n",
    "ax.plot(x, y, color=edgecolor, linewidth=3)\n",
    "\n",
    "for i,v in enumerate(zip(x,y)):\n",
    "    ax.plot(v[0], v[1], '.', color=vertexcolor, markersize=15)\n",
    "\n",
    "ax.text(x[0]+0.05,y[0]+0.05, r'$\\vec{r}_j$', fontsize=20, color=textcolor)\n",
    "ax.text(x[1],y[1]-0.15, r'$\\vec{r}_k$', fontsize=20, color=textcolor)\n",
    "ax.text((x[1]+x[0])/2,(y[1]+y[0])/2+0.05, r'$r$', fontsize=20, color=textcolor)\n",
    "   \n",
    "ax.grid(False)\n",
    "ax.axis('off')\n",
    "\n",
    "fig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "fig.savefig('../md-bond.svg', bbox_inches='tight', facecolor=(1, 1, 1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# dihedral\n",
    "x = [-1, -1, 1, 1]\n",
    "y = [-1, 0, 0, -1]\n",
    "z = [-1, 0, 0, 2]\n",
    "\n",
    "fig = matplotlib.figure.Figure(figsize=(10, 6.18), dpi=100)\n",
    "ax = fig.add_subplot(projection='3d', proj_type='ortho')\n",
    "ax.plot(x, y, z, color=edgecolor, linewidth=3)\n",
    "\n",
    "ax.plot_trisurf(x[0:3], y[0:3], z[0:3], alpha=0.2, color='C4')\n",
    "ax.plot_trisurf(x[1:4], y[1:4], z[1:4], alpha=0.2, color='C6')\n",
    "\n",
    "for i,v in enumerate(zip(x,y,z)):\n",
    "    ax.plot(v[0], v[1], v[2], '.', color=vertexcolor, markersize=15)\n",
    "\n",
    "ax.text(x[0],y[0],z[0]+0.2, r'$\\vec{r}_i$', fontsize=20)\n",
    "ax.text(x[1],y[1]-0.15,z[1]+0.1, r'$\\vec{r}_j$', fontsize=20)\n",
    "ax.text(x[2]+0.1,y[2],z[2], r'$\\vec{r}_k$', fontsize=20)\n",
    "ax.text(x[3]+0.1,y[3],z[3]+0.1, r'$\\vec{r}_l$', fontsize=20)\n",
    "\n",
    "ax.text(-0.2, -0.1, 0, r'$\\phi$', fontsize=20, ha='center', va='center')\n",
    "   \n",
    "ax.grid(False)\n",
    "ax.axis('off')\n",
    "# ax.set_xlabel('X')\n",
    "# ax.set_ylabel('Y')\n",
    "ax.view_init(azim=-30, elev=5, vertical_axis='z')\n",
    "ax.set_facecolor('white')\n",
    "\n",
    "fig\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "fig.savefig('../md-dihedral.svg', bbox_inches=matplotlib.transforms.Bbox([[3.2, 2], [7.3, 4.3]]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# dihedral\n",
    "x = [-1, -1, 1, 1]\n",
    "y = [-1, 0, 0, -1]\n",
    "z = [-1, 0, 0, 2]\n",
    "\n",
    "fig = matplotlib.figure.Figure(figsize=(10, 6.18), dpi=100)\n",
    "ax = fig.add_subplot(projection='3d', proj_type='ortho')\n",
    "ax.plot(x, y, z, color=edgecolor, linewidth=3)\n",
    "\n",
    "ax.plot_trisurf(x[0:3], y[0:3], z[0:3], alpha=0.2, color='C4')\n",
    "ax.plot_trisurf(x[1:4], y[1:4], z[1:4], alpha=0.2, color='C6')\n",
    "\n",
    "for i,v in enumerate(zip(x,y,z)):\n",
    "    ax.plot(v[0], v[1], v[2], '.', color=vertexcolor, markersize=15)\n",
    "\n",
    "ax.text(x[0],y[0],z[0]+0.2, r'$\\vec{r}_i$', fontsize=20)\n",
    "ax.text(x[1],y[1]-0.15,z[1]+0.1, r'$\\vec{r}_j$', fontsize=20)\n",
    "ax.text(x[2]+0.1,y[2],z[2], r'$\\vec{r}_k$', fontsize=20)\n",
    "ax.text(x[3]+0.1,y[3],z[3]+0.1, r'$\\vec{r}_l$', fontsize=20)\n",
    "\n",
    "ax.text(-0.2, -0.1, 0, r'$\\chi$', fontsize=20, ha='center', va='center')\n",
    "   \n",
    "ax.grid(False)\n",
    "ax.axis('off')\n",
    "# ax.set_xlabel('X')\n",
    "# ax.set_ylabel('Y')\n",
    "ax.view_init(azim=-30, elev=5, vertical_axis='z')\n",
    "ax.set_facecolor('white')\n",
    "\n",
    "fig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "fig.savefig('../md-improper.svg', bbox_inches=matplotlib.transforms.Bbox([[3.2, 2], [7.3, 4.3]]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
